﻿
using AnQinManagermentBackendAPI.Model.DTO.Login;
using AnQinManagermentBackendAPI.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace AnQinManagermentBackendAPI.Controller
{
    /// <summary>
    /// 登录接口
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        /**
         * 登录业务接口
         */
        private readonly LoginService _loginService;

        /**
         * 构造函数注入
         */
        public LoginController(LoginService loginService)
        {
            _loginService = loginService;
        }

        /// <summary>
        /// 登录
        /// </summary>
        [HttpPost]
        public async Task<IActionResult> Login([FromBody] LoginDTO loginDTO)
        {
            var response = await _loginService.Login(loginDTO);
            return StatusCode(response.Status, response);
        }

        /// <summary>
        /// 校验token
        /// </summary>
        [HttpPost("HandShake")]
        [Authorize]
        public async void HandShake()
        {

        }
    }
}
